package com.market2.utils.converter.impl;

import com.market2.dto.NegociationEnchereDto;
import com.market2.model.NegociationEnchere;
import com.market2.utils.converter.Converter;

public class NegociationEnchereConverter extends Converter
{
	@SuppressWarnings("unchecked") @Override
	public NegociationEnchereDto convertTo(Object source)
	{
		if(source == null || !(source instanceof NegociationEnchere)) {
			return null;
		}
		
		NegociationEnchereDto dto = new NegociationEnchereDto();
		NegociationEnchere nego = (NegociationEnchere) source;
		
		dto.setNumero(nego.getNumero());
		dto.setPrix(nego.getPrix());
		dto.setDateDebut(nego.getDateDebut());
		dto.setDateFin(nego.getDateFin());
		
		return dto;
	}

	@SuppressWarnings("unchecked") @Override
	public NegociationEnchere convertFrom(Object source)
	{
		if(source == null || !(source instanceof NegociationEnchereDto)) {
			return null;
		}
		
		NegociationEnchereDto dto =  (NegociationEnchereDto) source;
		NegociationEnchere nego = new NegociationEnchere();
		
		nego.setNumero(dto.getNumero());
		nego.setPrix(dto.getPrix());
		nego.setDateDebut(dto.getDateDebut());
		nego.setDateFin(dto.getDateFin());
		
		return nego;
	}
}
